const CryptoJS = require('crypto-js')   //导入模块

function watch(obj,name) {

}
// 接触bom代理
window = watch(globalThis,'window')
function Window() {}
function Document() {}
Document.prototype.documentElement = watch(new HTMLHtmlElement(),'document.documentElement')
function HTMLScriptElement() {
    this.tagName = 'SCRIPT'
    this.parentNode = {
        removeChild:function(args) {
            console.log('对象=>' + 'document.createElement.parentNode,方法 => removeChild:',args)
        }
    }
}
Object.defineProperty(Document.prototype,'createElement',{
    configurable:true,
    enumerable:true,
    writable:true,
    value: function createElement(tagName) {
        console.log('对象=>document,方法=>createElement创建元素:',tagName)
        if (tagName === 'script'){
            scr = watch(new HTMLScriptElement(),'script')
            return scr
        }
    }
})
Window.prototype.document = watch(new Document(),'document')

// window ==>Window.prototype
Object.setPrototypeOf(window,Window.prototype)

function Elements() {
    this.prototype = function() {
        return scrollIntoViewIfNeeded
    }
}
Element = watch(new Elements(),'Element')

require('./objectProde.js')

h = {
    "area": "4",
    "enc": "utf-8",
    "keyword": "电脑笔记本",
    "adType": 7,
    "page": "2",
    "ad_ids": "292:5",
    "xtest": "new_search"
}

g = {
    "appid": "search-pc-java",
    "functionId": "pc_search_adv_Search",
    "client": "pc",
    "clientVersion": "1.0.0",
    "t": (new Date).getTime()
}

g.body = CryptoJS.SHA256(JSON.stringify(h)).toString()
window.PSign= new ParamsSign({
    appId: "f06cc",
    debug: false,
    preRequest:false,
    onSign: function(data){
    if(data && data.code && data.code!=200){ console.log(JSON.stringify(data)) }
    },
    onRequestTokenRemotely: function(data){
    if(data && data.code && data.code!=0){ console.log(JSON.stringify(data)) }
    },
    onRequestToken: function(data){
    if(data && data.code && data.code!=0){ console.log(JSON.stringify(data)) }
    }
});
// this 面向对象，谁调用，指向谁
// this._$sdnmd(g)，这里的this指向window.PSign
h5stparams = window.PSign._$sdnmd(g)
console.log(h5stparams)